package bb.lanxing.util;

import java.util.LinkedList;

public class LimitedLinkedList<E> extends LinkedList<E> {
    private int limit;

    public LimitedLinkedList(int i) {
        this.limit = i;
    }

    @Override
    public boolean add(E e) {
        boolean add = super.add(e);
        while (add && size() > this.limit) {
            super.remove();
        }
        return add;
    }
}
